/// 用于定义事件类型，全局唯一性
class RikiEventType {
  static const String _PATTERN_CHAR = '|';

  const RikiEventType(this._value);

  final String _value;

  String get value => _value.split(_PATTERN_CHAR).first;

  String? get subtitle {
    List<String> temp = _value.split(_PATTERN_CHAR);
    return temp.length > 2 ? temp[1] : null;
  }

  String get package => _value.split(_PATTERN_CHAR).last;

  bool get isCompliance => _value.split(_PATTERN_CHAR).length == 2 || _value.split(_PATTERN_CHAR).length == 3;

  @override
  String toString() => 'Package:$package,RikiEventType.$value${subtitle != null ? '$_PATTERN_CHAR$subtitle' : ''}';

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) {
      return true;
    }
    if (other.runtimeType != runtimeType) {
      return false;
    }
    return other is RikiEventType && other.value == value;
  }

  @override
  int get hashCode => value.hashCode;
}
